package com.foreveross.fetl.common.vo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.StringUtils;


public class PlaneInfo {

	
	private String id="";
	
	
	//carrierInfo
	/**
	 * 运营商简称英文，如：MU
	 */
	private String carrierKey="";
	/**
	 * [返程]运营商简称英文，如：MU
	 */
	private String roundCarrierKey="";
	
	private String SOURCE_ROWKEY;
	
	/**
	 * 运营商简称中文，如：南航
	 */
	private String carrierName="";
	/**
	 * [返程]运营商简称中文，如：南航
	 */
	private String roundCarrierName="";
	
	/**
	 * 运营商全名，如：中国海南航空公司
	 */
	private String carrierFullName="";
	/**
	 * [返程]运营商全名，如：中国海南航空公司
	 */
	private String roundCarrierFullName="";
	
	private String grabChannelId;
	
	
	//flightInfo
//	/**
//	 * 航班批次，MU3540|2012-05-19
//	 */
//	private String flightBatch="";
	
	/**
	 * 航班批次日期。2012-05-19
	 */
	private String flightBatchDate="";
	/**
	 * [返程]航班批次日期。2012-05-19
	 */
	private String roundFlightBatchDate="";
	
	/**
	 * 航班起飞时间
	 */
	private String flightBatchStartTime="";

	/**
	 * [返程]航班起飞时间
	 */
	private String roundFlightBatchStartTime="";
	
	/**
	 * 航班预计到达时间
	 */
	private String flightBatchEndTime="";
	/**
	 * [返程]航班预计到达时间
	 */
	private String roundFlightBatchEndTime="";
	
	/**
	 * 航班批次id，如：
	 * MU3540|2012-05-19
	 */
	private String flightId="";
	
	private String cabinInfos;
	
	/**
	 * 目的地
	 */
	private String toCity="";
	
	private String timstamp;
	public String getTimstamp() {
		return timstamp;
	}


	public void setTimstamp(String timstamp) {
		this.timstamp = timstamp;
	}
	private String toCityName="";
	public String getToCityName() {
		return toCityName;
	}


	public String getSOURCE_ROWKEY() {
		return SOURCE_ROWKEY;
	}


	public void setSOURCE_ROWKEY(String sOURCE_ROWKEY) {
		SOURCE_ROWKEY = sOURCE_ROWKEY;
	}


	public void setToCityName(String toCityName) {
		this.toCityName = toCityName;
	}
	/**
	 * 起飞地(源)
	 * 
	 */
	private String fromCity="";
	
	private String fromCityName="";
	
	private String grabDate;
	
	
	
	public String getGrabChannelId() {
		return grabChannelId;
	}


	public void setGrabChannelId(String grabChannelId) {
		this.grabChannelId = grabChannelId;
	}


	public String getAreaCode() {
		return areaCode;
	}


	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}


	public String getFromCityName() {
		return fromCityName;
	}


	public void setFromCityName(String fromCityName) {
		this.fromCityName = fromCityName;
	}

	
	//planeInfo
	
	
	/**
	 * 最低价格
	 */
	private String lowerPrice="";
	
	
	/**
	 * 最高价格
	 */
	private String highPrice="";
	
	/**
	 * 抓取渠道
	 */
	private String grabChannel="";
	/**
	 * 代理商信息
	 */
	private List<AgentInfo> agentInfos;
	
	/**
	 * 飞机类型
	 */
	private String type="";
	
	/**
	 * 代理商名字
	 */
	private String agentName="";
	
	/**
	 * 
	 */
	private String grapDate;
	
	private String grabChannelNum;
	/**
	 * 区域名
	 */
	private String areaName;
	
	/**
	 * 区域ID
	 * 
	 */
	
	private String areaId;
	
	private String areaCode;
		
	public String getLowerPrice() {
		return lowerPrice;
	}


	public void setLowerPrice(String lowerPrice) {
		this.lowerPrice = lowerPrice;
	}


	public String getGrabChannelNum() {
		return grabChannelNum;
	}


	public void setGrabChannelNum(String grabChannelNum) {
		this.grabChannelNum = grabChannelNum;
	}


	public String getAreaName() {
		return areaName;
	}


	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}


	public String getAreaId() {
		return areaId;
	}


	public void setAreaId(String areaId) {
		this.areaId = areaId;
	}


	public String getGrapDate() {
		return grapDate;
	}


	public void setGrapDate(String grapDate) {
		this.grapDate = grapDate;
	}


	public String getType() {
		return type;
	}


	public void setType(String type) {
		this.type = type;
	}


	public String getGrabChannel() {
		return grabChannel;
	}


	public void setGrabChannel(String grabChannel) {
		this.grabChannel = grabChannel;
	}


	public String getGrabDate() {
		return grabDate;
	}


	public void setGrabDate(String grabDate) {
		this.grabDate = grabDate;
	}


	public List<AgentInfo> getAgentInfos() {
		return agentInfos;
	}


	public void setAgentInfos(List<AgentInfo> agentInfos) {
		this.agentInfos = agentInfos;
	}


	public String getCarrierKey() {
		return carrierKey;
	}


	public void setCarrierKey(String carrierKey) {
		this.carrierKey = carrierKey;
	}


	public String getCarrierName() {
		return carrierName;
	}


	public void setCarrierName(String carrierName) {
		this.carrierName = carrierName;
	}


	public String getCarrierFullName() {
		return carrierFullName;
	}


	public void setCarrierFullName(String carrierFullName) {
		this.carrierFullName = carrierFullName;
	}


//	public String getFlightBatch() {
//		return flightBatch;
//	}
//
//
//	public void setFlightBatch(String flightBatch) {
//		this.flightBatch = flightBatch;
//	}


	public String getFlightBatchDate() {
		return flightBatchDate;
	}


	public void setFlightBatchDate(String flightBatchDate) {
		this.flightBatchDate = flightBatchDate;
	}


	


	public String getFlightBatchStartTime() {
		if(flightBatchStartTime.indexOf(":")>0){
			return flightBatchStartTime;
		}else{
			return flightBatchStartTime.substring(0,2)+":"+flightBatchStartTime.substring(2,flightBatchStartTime.length());
		}
		
	}


	public void setFlightBatchStartTime(String flightBatchStartTime) {
		this.flightBatchStartTime = flightBatchStartTime;
	}


	public String getFlightBatchEndTime() {
		if(flightBatchEndTime.indexOf(":")>0){
			return flightBatchEndTime;
		}else{
			return flightBatchEndTime.substring(0,2)+":"+flightBatchEndTime.substring(2,flightBatchEndTime.length());
		}
	}


	public void setFlightBatchEndTime(String flightBatchEndTime) {
		this.flightBatchEndTime = flightBatchEndTime;
	}


	public String getFlightId() {
		return flightId;
	}


	public void setFlightId(String flightId) {
		this.flightId = flightId;
	}




	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}


	public String getHighPrice() {
		return highPrice;
	}


	public void setHighPrice(String highPrice) {
		this.highPrice = highPrice;
	}


	public String getToCity() {
		return toCity;
	}


	public void setToCity(String toCity) {
		this.toCity = toCity;
	}


	public String getFromCity() {
		return fromCity;
	}


	public void setFromCity(String fromCity) {
		this.fromCity = fromCity;
	}


	public String getAgentName() {
		return agentName;
	}


	public void setAgentName(String agentName) {
		this.agentName = agentName;
	}


	public String getRoundCarrierKey() {
		return roundCarrierKey;
	}


	public void setRoundCarrierKey(String roundCarrierKey) {
		this.roundCarrierKey = roundCarrierKey;
	}


	public String getRoundCarrierName() {
		return roundCarrierName;
	}


	public void setRoundCarrierName(String roundCarrierName) {
		this.roundCarrierName = roundCarrierName;
	}


	public String getRoundCarrierFullName() {
		return roundCarrierFullName;
	}


	public void setRoundCarrierFullName(String roundCarrierFullName) {
		this.roundCarrierFullName = roundCarrierFullName;
	}


	public String getRoundFlightBatchDate() {
		return roundFlightBatchDate;
	}


	public void setRoundFlightBatchDate(String roundFlightBatchDate) {
		this.roundFlightBatchDate = roundFlightBatchDate;
	}


	public String getRoundFlightBatchStartTime() {
		return roundFlightBatchStartTime;
	}


	public void setRoundFlightBatchStartTime(String roundFlightBatchStartTime) {
		this.roundFlightBatchStartTime = roundFlightBatchStartTime;
	}


	public String getRoundFlightBatchEndTime() {
		return roundFlightBatchEndTime;
	}


	public void setRoundFlightBatchEndTime(String roundFlightBatchEndTime) {
		this.roundFlightBatchEndTime = roundFlightBatchEndTime;
	}
	/**
	 * 得到起飞时间
	 * <p>由flightBatchDate+flightBatchStartTime组合而成
	 * @return
	 * @throws ParseException 
	 */
	public Date getFlightStartTime() throws ParseException{
		if(StringUtils.isNotEmpty(flightBatchDate) && StringUtils.isNotEmpty(flightBatchStartTime)){
			String time = flightBatchStartTime.indexOf(":") > -1 ? flightBatchStartTime.replace(":", "") : flightBatchStartTime;
			if(time.length() == 3)  time = "0"+time;
			else if(time.length() == 2) time = "00"+time;
			else if(time.length() == 1) time = "000"+time;
			
			return parse(flightBatchDate+" "+time, "yyyy-MM-dd HHmm");
		}
		return null;
	}
	/**
	 * 得到起飞时间
	 * <p>由flightBatchDate+flightBatchEndTime组合而成,暂不考虑跨天了
	 * @return
	 * @throws ParseException 
	 */
	public Date getFlightEndTime() throws ParseException{
		if(StringUtils.isNotEmpty(flightBatchDate) && StringUtils.isNotEmpty(flightBatchEndTime)){
			String time = flightBatchEndTime.indexOf(":") > -1 ? flightBatchEndTime.replace(":", "") : flightBatchEndTime;
			if(time.length() == 3)  time = "0"+time;
			else if(time.length() == 2) time = "00"+time;
			else if(time.length() == 1) time = "000"+time;
			return parse(flightBatchDate+" "+time, "yyyy-MM-dd HHmm");
		}
		return null;
	}


	public String getCabinInfos() {
		return cabinInfos;
	}


	public void setCabinInfos(String cabinInfos) {
		this.cabinInfos = cabinInfos;
	}
	
	private Date parse(String dateString,String pattern){
		SimpleDateFormat sdf = new SimpleDateFormat(pattern);
		try {
			return sdf.parse(dateString);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
	
}
